﻿using Ozone.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace Ozone.Views.SystemCenter.LiquidRatioMethod
{
    /// <summary>
    /// LiquidRatioMethodItemBottle.xaml 的交互逻辑
    /// </summary>
    public partial class LiquidRatioMethodItemBottle : Window
    {
        public ObtainParam obtainParam;

        Dictionary<int, string> bottleDict = new Dictionary<int, string>();
        public LiquidRatioMethodItemBottle(ObtainParam obtainParam_)
        {
            InitializeComponent();
            InitializeBottleData();
            //obtainParam = obtainParam_;
        }



        private void InitializeBottleData()
        {
            // 添加瓶子数据
            bottleDict.Add(1, "甲烷");
            bottleDict.Add(2, "丙烷");
            bottleDict.Add(3, "丁烷");
            bottleDict.Add(4, "酒精");
            bottleDict.Add(5, "甲苯");
            bottleDict.Add(6, "乙酸");

            // 绑定数据到ComboBox
            cmbFBottleNO.ItemsSource = bottleDict;
            cmbFBottleNO.DisplayMemberPath = "Key";  // 显示Value（瓶子名称）
            cmbFBottleNO.SelectedValuePath = "Key";    // 实际值为Key

            // 设置默认选择
            cmbFBottleNO.SelectedIndex = 0;

            // 初始化TextBox显示
            UpdateBottleNameDisplay();
        }
        private void UpdateBottleNameDisplay()
        {
            if (cmbFBottleNO.SelectedItem != null)
            {
                // 获取选中的KeyValuePair
                KeyValuePair<int, string> selectedItem = (KeyValuePair<int, string>)cmbFBottleNO.SelectedItem;
                BottleName.Text = selectedItem.Value;
            }
        }

        /// <summary>
        /// 确定
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnAdd_Click(object sender, RoutedEventArgs e)
        {
            obtainParam.FBottleNo = Convert.ToInt32(cmbFBottleNO.Text);
            obtainParam.FName = BottleName.Text;
            obtainParam.FBarcode = "";
            obtainParam.FDensity = "";
            obtainParam.FWeightVolume = AddVolume.Text;
            DialogResult = true;
            Close();
        }

        /// <summary>
        /// 取消
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnClose_Click(object sender, RoutedEventArgs e)
        {
            DialogResult = false;
            Close();
        }

        private void cmbFBottleNO_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            UpdateBottleNameDisplay();
        }
    }
}
